<template>
  <el-table
    :data="tableData"
    border
    style="width: 100%">
     <el-table-column fixed prop="id" label="编号" width="150">
    </el-table-column>
    <el-table-column  prop="create_time" label="日期" width="180">
        <template slot-scope="scope">
            <span>{{ moment(scope.row.create_time).format('YYYY-MM-DD HH:mm:ss') }}</span>
          </template>
    </el-table-column>
    <el-table-column prop="category"  label="姓名" width="150">
    </el-table-column>
    <el-table-column
      prop="sellPoint"
      label="省份"
      width="150">
    </el-table-column>
    <el-table-column
      prop="num"
      label="地址"
      width="300">
    </el-table-column>
    <el-table-column
      label="操作"
      width="150">
      <template slot-scope="scope">
        <el-button @click="handleDelete(scope.$index,scope.row)" type="danger" icon="el-icon-delete">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
 
</template>

<script>
import moment from 'moment'
  export default {
    created() {
      this.projectList()
    },
    methods: {
      moment,
      handleDelete(index,row) {
     console.log(index,row);
             this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
        this.deleteItemById(row.id)
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
      },
        //获取产品列表
      async projectList(page){
        let res = await this.$api.projectList({page})
        console.log('产品表数据',res.data);
        this.tableData=res.data.data
      },
        // 删除接口
      async deleteItemById(id){
        let res = await this.$api.deleteItemById({id})
        console.log(res.data);
        if(res.data.status===200){
          this.$message({
            type:'success',
            message:"删除成功"
          })

        }
        this.projectList(1)
    },
},
    data() {
      return {
        // dialogVisible:'false',
        tableData: []
      }
    }
  
  }
</script>

<style>

</style>